<!DOCTYPE html>
<html class="x-admin-sm" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>P T 领贤兼职 login</title>
    <meta content="webkit|ie-comp|ie-stand" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" name="viewport" />
    <link rel="stylesheet" th:href="@{/layui/css/font.css}">
    <link rel="stylesheet" th:href="@{/layui/css/login.css}">
    <link rel="stylesheet" th:href="@{/layui/css/xadmin.css}">
    <script th:src="@{/layui/js/jquery.min.js}" type="text/javascript"></script>
    <script charset="utf-8" th:src="@{/layui/lib/layui/layui.js}"></script>
    <link rel="stylesheet" th:href="@{/css/verify.css}">
    <script th:src="@{/js/verify.js}" type="text/javascript"></script>
    <style>
        a:link,a:visited,a:hover,a:active {
            margin-left: 100px;
            color: #0366D6;
        }
        .login {
            margin: 160px auto auto auto;
        }
    </style>
</head>
<body class="login-bg" th:style="'background: url('+'/images/login.jpg'+') no-repeat;background-size: 100% 110%;'">

<div class="login layui-anim layui-anim-up">
    <div class="message">P T 领贤兼职 校园账号登录</div>
    <div id="darkbannerwrap"></div>
    <form class="layui-form" method="post" >
        <label>
            <input class="layui-input" lay-verify="required"  name="email" placeholder="电子邮箱" type="text" >
        </label>
        <hr class="hr15">
        <label>
            <input class="layui-input" lay-verify="required" name="password" placeholder="密码" type="password">
        </label>
        <hr class="hr15">
        <input lay-filter="login" lay-submit style="width:100%;" type="submit" value="登录">
        <hr class="hr10" >
    </form>
</div>

<script>
    layui.use('form', function(){
        const form = layui.form;

        //监听提交
        form.on('submit(login)', function(data){
            $.ajax({
                url : "/university_login_in",
                method : 'post',
                data : data.field,
                dataType : 'JSON',
                success:function(res){
                    if(res.code === 0){
                        //弹出提示，并在1秒后进行跳转
                        layer.msg("登录成功",{icon: 1, time: 1000},function(){
                            location.href='/university_index';
                            return false;
                        });
                    }else{
                        layer.msg("登录失败: 账号、密码或验证有误");
                        return false;
                    }
                },
                //请求的页面响应失败，则进行处理：
                error:function (data) {
                    layer.msg(JSON.stringify(data.field),function(){
                        location.reload();
                    });
                    return false;
                }
            });
            return false;
        });
    });
</script>
<!-- 底部结束 -->
</body>
</html>